x86: also use tzcnt instead of bsf in __scanbit()
authorJan Beulich <jbeulich@suse.com>
Wed, 28 Jan 2015 15:29:46 +0000 (16:29 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 28 Jan 2015 15:29:46 +0000 (16:29 +0100)
commit2eb41660bf1d1210e56856a084b998a5a514c3e2
tree7026de6696c0b6608189d1177d2b4b8fcb4f059c
parenta4a0066eb132154e925d3d427ae883aaf3e78cbd
x86: also use tzcnt instead of bsf in __scanbit()

... when available, i.e. by runtime patching. This saves the
conditional move, having a back-to-back dependency on BSF's (EFLAGS)
result.

The need to include asm/cpufeatures.h from asm/bitops.h requires a
workaround for an otherwise resulting circular header file dependency:
Provide a mode by which the including site of the former header can
request to only get the X86_FEATURE_* defines (and very little more)
from it, allowing it to nevertheless be included in its entirety later
on.

While doing this I also noticed that the function's "max" parameter was
pointlessly "unsigned long" - the function only returning
"unsigned int", this can't be of any use, and hence gets converted at
once, along with the necessary adjustments to CMOVZ's output operands.

Note that while only alternative_io() is needed by this change (and
hence gets pulled over from Linux), for completeness its input-only
counterpart alternative_input() gets added as well.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/include/asm-x86/alternative.h
xen/include/asm-x86/bitops.h
xen/include/asm-x86/cpufeature.h